package com.wlz.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *  Topics模式  交换机类型 topic
 * @author wlz
 * @date 2022-06-29  10:07 下午
 */
@Configuration
public class TopicConfig {

    /**
     *  声明 队列
     * @return
     */
    @Bean
    public Queue topicQueue1() {
        return new Queue("wlz_topic_queue_1");
    }

    @Bean
    public Queue topicQueue2() {
        return new Queue("wlz_topic_queue_2");
    }


    /**
     *  声明 exchange
     * @return
     */
    @Bean
    public TopicExchange setTopicExchange() {
        return new TopicExchange("wlz_topic_exchange");
    }

    /**
     *  声明 binding , 需要声明 一个 routingkey
     * @return
     */
    @Bean
    public Binding bindTopicBind1() {
        return BindingBuilder.bind(topicQueue1()).to(setTopicExchange()).with("wlz.*");
    }

    /**
     *  声明 binding , 需要声明 一个 routingkey
     * @return
     */
    @Bean
    public Binding bindTopicBind2() {
        return BindingBuilder.bind(topicQueue2()).to(setTopicExchange()).with("#.bbb");
    }

}
